<template>
	<view class="">
		<view class="item u-flex" v-for="item in list" :key="item.id" @click="gotodetail(item.id)">
			<view class="title flex">
				<view class="name">
					<text>{{item.name}}</text>
				</view>
				<view class="distance flex" v-if="distance">
					<image class="icon" src="@/static/home/distance.png" mode="aspectFill"></image>
					<text>{{item.distance ? (item.distance).toFixed(2) : 0}}km</text>
				</view>
			</view>
			<view class="tags u-flex">
				<text class="station">{{ stationTypeText[item.stationType] || '普通' }}</text>
				<text class="tag" v-if="item.labels" v-for="(tag, index) in item.labels">{{ tag }}</text>
			</view>

			<view class="charging flex" style="margin-bottom: 20rpx;">
				<view class="label flex super" style="justify-content: center;" v-if="item.superFastCharging">
					<view class="status"><text class="text">超</text></view>
					<view class="value flex">
						<text class="text1">闲 {{item.superFastCharging.available}}</text>
						<text class="text2">/{{item.superFastCharging.total}}</text>
					</view>
				</view>

				<view class="label flex fast" style="justify-content: center;" v-if="item.fastCharging">
					<view class="status"><text class="text">快</text></view>
					<view class="value flex">
						<text class="text1">闲 {{ item.fastCharging.available }}</text>
						<text class="text2">/{{ item.fastCharging.total }}</text>
					</view>
				</view>

				<view class="label flex slow" style="justify-content: center;" v-if="item.slowCharging">
					<view class="status"><text class="text">慢</text></view>
					<view class="value flex">
						<text class="text1">闲 {{item.slowCharging.available}}</text>
						<text class="text2">/{{item.slowCharging.total}}</text>
					</view>
				</view>
			</view>

			<view class="price flex">
				<text class="symbol">¥</text>
				<text class="text">{{item.price || 0}}</text>
				<text class="unit">/度</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array
			},
			distance: {
				type: Boolean
			}
		},
		data() {
			return {
				stationTypeText: {
					0: '普通',
					1: '快速',
					2: '超充',
					3: '综合站'
				}
			}
		},
		methods: {
			gotodetail(id) {
				this.$emit('gotodetail', id)
			}
		}
	}
</script>

<style scoped lang="scss">
	@import url('~@/static/css/station.css');
	
	.item {
		padding: 30rpx;
		background: #fff;
		position: relative;
		margin-bottom: 1rpx;

		&:not(:last-child)::after {
			position: absolute;
			content: "";
			bottom: 0;
			left: 20rpx;
			right: 20rpx;
			height: 1rpx;
			background: #eee;
		}

		.title {
			margin-bottom: 15rpx;
			justify-content: space-between;

			.name {
				flex: 1;
				padding-right: 20rpx;

				text {
					color: #333333;
					font-size: 32rpx;
					font-weight: 600;
					font-family: "PINGFANG";
				}
			}

			.distance {
				.icon {
					width: 16rpx;
					height: 16rpx;
				}

				text {
					color: #777777;
					font-size: 22rpx;
					font-weight: 400;
					font-family: "PINGFANG";
					margin-left: 5rpx;
				}
			}
		}

		.tags {
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			line-height: 0;

			.station {
				font-family: "PINGFANG";
				font-size: 15rpx;
				color: #FF720A;
				background: #FDF7F0;
				border-radius: 7rpx;
				border: 1rpx solid #FF720A;
				padding: 2rpx 5rpx;
				line-height: 20rpx;
				margin-right: 10rpx;
				position: relative;
				top: -6rpx;
			}

			.tag {
				font-weight: 400;
				font-family: "PINGFANG";
				color: #777777;
				font-size: 20rpx;
				margin-right: 10rpx;
				padding-right: 10rpx;
				position: relative;
				line-height: 20rpx;
				margin-bottom: 15rpx;

				&:not(:last-child)::after {
					content: '';
					position: absolute;
					height: 10rpx;
					width: 1rpx;
					background: #AAAAAA;
					right: 0;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}

		.price {
			align-items: baseline;

			.symbol {
				color: #FC0A01;
				font-family: "PINGFANG";
				font-weight: 600;
				font-size: 22rpx;
				margin-right: 5rpx;
			}

			.text {
				color: #FC0A01;
				font-family: "PINGFANG";
				font-weight: 600;
				font-size: 32rpx;
				letter-spacing: 1rpx;
			}

			.unit {
				color: #333;
				font-family: "PINGFANG";
				font-weight: 400;
				font-size: 17rpx;
			}
		}
	}
</style>